//optype==1 price optype == 2 amount
function buyPlanTurnoverValue(optype,event){
    var type = document.getElementById("buyType");
    var amount = document.getElementById("buyAmount");
    var cnyPrice = document.getElementById("buyCnyPrice");
    var turnoverin = document.getElementById("buyTurnoverin");
    var bitTips = document.getElementById("buyBtcTips");
    var feeTips = document.getElementById("buyFeeTips");
    var feeTipsValue = document.getElementById("buyFeeTipsValue");
    tradeTurnoverValue(type,amount,cnyPrice,turnoverin,feeTips,feeTipsValue,bitTips,optype,event);
}

function sellPlanTurnoverValue(optype,event){
    var type = document.getElementById("sellType");
    var amount = document.getElementById("sellAmount");
    var cnyPrice = document.getElementById("sellCnyPrice");
    var turnoverin = document.getElementById("sellTurnoverin");
    var feeTips = document.getElementById("sellFeeTips");
    var bitTips = document.getElementById("sellBtcTips");
    var feeTipsValue = document.getElementById("sellFeeTipsValue");
    tradeTurnoverValue(type,amount,cnyPrice,turnoverin,feeTips,feeTipsValue,bitTips,optype,event);
}

function buyPlanSummoneyValue(event){
    var type = document.getElementById("buyType");
    var amount = document.getElementById("buyAmount");
    var cnyPrice = document.getElementById("buyCnyPrice");
    var turnoverin = document.getElementById("buyTurnoverin");
    var bitTips = document.getElementById("buyBtcTips");
    var feeTips = document.getElementById("buyFeeTips");
    var feeTipsValue = document.getElementById("buyFeeTipsValue");
    summoneyValue(type,amount,cnyPrice,turnoverin,feeTips,feeTipsValue,bitTips,event);
}

function sellPlanSummoneyValue(event){
    var type = document.getElementById("sellType");
    var amount = document.getElementById("sellAmount");
    var cnyPrice = document.getElementById("sellCnyPrice");
    var turnoverin = document.getElementById("sellTurnoverin");
    var feeTips = document.getElementById("sellFeeTips");
    var bitTips = document.getElementById("sellBtcTips");
    var feeTipsValue = document.getElementById("sellFeeTipsValue");
    summoneyValue(type,amount,cnyPrice,turnoverin,feeTips,feeTipsValue,bitTips,event);
}

function tradeTurnoverValue(type,amount,cnyPrice,turnoverin,feeTips,feeTipsValue,btcTips,optype,event){
    var isreturn = ctrlAorTab(event);
    if(isreturn){
        return;
    }
    var tradeType = type?type.value:"";
    var tradeAmount = 0;
    var tradeCnyPrice = 0;
    if(optype == 2){
        var  amountSelectionStart = getPositionForInput(amount);
        tradeAmount = amount.value=checkNumberByObj(amount,4);
        setCursorPosition(amount,amountSelectionStart);
    }else{
        tradeAmount = amount?amount.value:"";
    }
    if(optype == 1){
        var  amountSelectionStart = getPositionForInput(cnyPrice);
        tradeCnyPrice = cnyPrice.value=checkNumberByObj(cnyPrice,4);
        setCursorPosition(cnyPrice,amountSelectionStart);
    }else{
        tradeCnyPrice = cnyPrice?cnyPrice.value:"";
    }
    var reg=/^(-?\d*)\.?\d{1,4}$/;
    var symbol = document.getElementById("symbol").value;
    if(tradeAmount!=null && tradeAmount.toString().split(".")!=null && tradeAmount.toString().split(".")[1]!=null && tradeAmount.toString().split(".")[1].length>4){
        if(!reg.test(tradeAmount)){
            amount.value = tradeAmount.substring(0, tradeAmount.length-1);
            return false;
        }
    }
    if(tradeCnyPrice!=null && tradeCnyPrice.toString().split(".")!=null && tradeCnyPrice.toString().split(".")[1]!=null && tradeCnyPrice.toString().split(".")[1].length>4){
        if(!reg.test(tradeCnyPrice)){
            cnyPrice.value = tradeCnyPrice.substring(0, tradeCnyPrice.length-1);
            return false;
        }
    }
    var turnover = tradeAmount*tradeCnyPrice;
    if(turnover!= null && turnover.toString().split(".")!=null && turnover.toString().split(".")[1] != null && turnover.toString().split(".")[1].length>4){
        turnover = turnover.toFixed(4);
    }
    if(turnoverin){
        turnoverin.value = turnover;
    }
    if(tradeType ==1){
        var marketed = document.getElementById("buyMarketedType").value;
        if(marketed == 0){
            var tradeTurnover = tradeAmount*tradeCnyPrice;
            if(document.getElementById("userCnyBalance")!=null &&  Number(document.getElementById("userCnyBalance").value) <  Number(tradeTurnover)){
                alertTipsSpan(btcTips,balanceisinsufficient);
                return;
            }else{
                clearTipsSpan(btcTips);
            }
        }else{
            if(document.getElementById("userCnyBalance")!=null &&  Number(document.getElementById("userCnyBalance").value) < Number(tradeAmount)){
                alertTipsSpan(btcTips,balanceisinsufficient);
                return;
            }else{
                clearTipsSpan(btcTips);
            }
        }
    }else{
        if(document.getElementById("userBtcBalance")!=null && Number(document.getElementById("userBtcBalance").value ) < Number(tradeAmount)){
            //newCoinLabel
            if(symbol == 0){
                alertTipsSpan(btcTips,buytradejs2);
            }else if (symbol == 1){
                alertTipsSpan(btcTips,buytradejs3);
            }
            return;
        }else{
            clearTipsSpan(btcTips);
            if(feeTips){
                feeTips.innerHTML = feeTipsValue.value;
            }
        }
    }
}
function summoneyValue(type,amount,cnyPrice,turnoverin,feeTips,feeTipsValue,btcTips,event){
    var isreturn = ctrlAorTab(event);
    if(isreturn){
        return;
    }
    var tradeType = type?type.value:"";
    var  turnoverSelectionStart = getPositionForInput(turnoverin);
    var tradeTurnover = turnoverin?turnoverin.value=(function (a) {return a.length > 1 ? a.shift().replace(/\D/g, '') + '.' + a.join('').replace(/\D/g, '').slice(0, 4) : a[0].replace(/\D/g,'');})(turnoverin.value.split('.')):"";
    setCursorPosition(turnoverin,turnoverSelectionStart);
    var tradeCnyPrice = cnyPrice?cnyPrice.value:"";
    var tradeAmount = amount?amount.value:"";
    var symbol = document.getElementById("symbol").value;
    if(tradeCnyPrice!=0){
        tradeAmount = tradeTurnover/tradeCnyPrice;
    }else {
        tradeAmount = 0;
    }
    if(tradeAmount!= null && tradeAmount.toString().split(".")!=null &&tradeAmount.toString().split(".")[1] != null && tradeAmount.toString().split(".")[1].length>4){
        tradeAmount = tradeAmount.toFixed(4);
    }
    if(amount){
        amount.value = tradeAmount;
    }
    var reg=/^(-?\d*)\.?\d{1,4}$/;
    if(tradeTurnover!=null && tradeTurnover.toString().split(".")!=null && tradeTurnover.toString().split(".")[1]!=null && tradeTurnover.toString().split(".")[1].length>4){
        if(!reg.test(tradeTurnover)){
            turnoverin.value = tradeTurnover.substring(0, tradeTurnover.length-1);
            return false;
        }
    }
    if(tradeType ==1){
        if(document.getElementById("userCnyBalance")!=null && Number(document.getElementById("userCnyBalance").value) < Number(tradeTurnover)){
            alertTipsSpan(btcTips,balanceisinsufficient);
            return;
        }else{
            clearTipsSpan(btcTips);
            if(feeTips){
                feeTips.innerHTML = feeTipsValue.value;
            }

        }
    }else{
        if(document.getElementById("userBtcBalance")!=null && Number(document.getElementById("userBtcBalance").value ) < Number(tradeAmount)){
            //newCoinLabel
            if(symbol == 0){
                alertTipsSpan(btcTips,buytradejs2);
            }else if (symbol == 1) {
                alertTipsSpan(btcTips,buytradejs3);
            }
            return;
        }else{
            clearTipsSpan(btcTips);
            if(feeTips){
                feeTips.innerHTML = feeTipsValue.value;
            }
        }
    }
}
function buyPlanBtc(){
    var buyAmount =document.getElementById("buyAmount").value;
    var buyCnyPrice =document.getElementById("buyCnyPrice").value;
    var buyPwd = trim(document.getElementById("buyPwd").value);
    var buyType = document.getElementById("buyType").value;
    var btcTips = document.getElementById("buyBtcTips");
    var btcTriggerPrice = document.getElementById("buyTriggerPrice").value;
    planBtcSubmitForm(buyAmount,buyCnyPrice,buyPwd,buyType,btcTips,btcTriggerPrice,"planToBuyBtc","planToSellBtc");
}

var check = 1;

function clearTipsSpan(btcTips){
    if(btcTips){
        btcTips.style.display="";
        btcTips.innerHTML="";
    }
}

function alertTipsSpan(btcTips,tips){
    btcTips.style.display="";
    btcTips.innerHTML=tips;
    setTimeout(function (){
        clearTipsSpan(btcTips);
    },3000);
}

function triggerPriceKeyup(obj,type){
    var value = obj.value;
    var name = "buyTriggerPrice";
    if(type==1){
        name = "sellTriggerPrice";
    }
    if(value!=null){
        var  objPosition = getPositionForInput(obj);
        obj.value =  checkNumberByName(name);
        setCursorPosition(obj,objPosition);
    }
}



////这是跟踪委托的↓↓↓↓↓
function keyUp(obj,name){
    var value = obj.value;
    if(value!=null){
        var  objPosition = getPositionForInput(obj);
        obj.value =  checkNumberByName(name);
        setCursorPosition(obj,objPosition);
    }
}

function rangeKeyUp(obj,name){
    var number = document.getElementById(name).value.split('.');
    var objPosition = getPositionForInput(obj);
    if(number.length > 1){
        obj.value = number[0].replace(/\D/g, '') + '.' + number[1].replace(/\D/g, '').slice(0, 2);
    }else{
        obj.value =  number[0].replace(/\D/g,'');
    }
    setCursorPosition(obj,objPosition);
}

function alertSpanTigs(type,content){
    if(type == 1){
        document.getElementById("buyTrackTigs").innerHTML=content;
    }else{
        document.getElementById("sellTrackTigs").innerHTML=content;
    }
}

function clearSpanTigs(type){
    if(type == 1){
        document.getElementById("buyTrackTigs").innerHTML="";
    }else{
        document.getElementById("sellTrackTigs").innerHTML="";
    }
}

var trackCheck = 1 ;

function refrushWindow(){
    window.location.href = window.location.href;
}

function clearParamters(type){
    if(type == 1){
        document.getElementById("buyTradeValue").value="";
        document.getElementById("buyRatio").value="";
        document.getElementById("buyProtePrice").value="";
        document.getElementById("trackBuyPwd").value="";

    }else{
        document.getElementById("sellTradeValue").value="";
        document.getElementById("sellRatio").value="";
        document.getElementById("sellProtePrice").value="";
        document.getElementById("trackSellPwd").value="";

    }
}

var conCheck =1 ;

function signChange(type,value){
    if(type == 1){
        if(value == 1){
            jQuery("#buyAdd").removeClass("addBg");
            jQuery("#buyAdd").addClass("addBgBlue");
            jQuery("#buyMinus").addClass("minusBg");
            jQuery("#buyMinus").removeClass("minusBgBlue");
        }else{
            jQuery("#buyAdd").addClass("addBg");
            jQuery("#buyAdd").removeClass("addBgBlue");
            jQuery("#buyMinus").removeClass("minusBg");
            jQuery("#buyMinus").addClass("minusBgBlue");
        }
        document.getElementById("buySign").value = value;
    }else{
        if(value == 1){
            jQuery("#sellAdd").removeClass("addBg");
            jQuery("#sellAdd").addClass("addBgBlue");
            jQuery("#sellMinus").addClass("minusBg");
            jQuery("#sellMinus").removeClass("minusBgBlue");
        }else{
            jQuery("#sellAdd").addClass("addBg");
            jQuery("#sellAdd").removeClass("addBgBlue");
            jQuery("#sellMinus").removeClass("minusBg");
            jQuery("#sellMinus").addClass("minusBgBlue");
        }
        document.getElementById("sellSign").value = value;
    }
}

var iniCheck = 1;


function showEntrustAgreement(){
    dialogBoxShadow();
    document.getElementById("entrustAgreement").style.display="";
    addMoveEvent("Agreement_title","Agreement_content");
}
function closeEntrustAgreement(){
    dialogBoxHidden();
    document.getElementById("entrustAgreement").style.display="none";
}

function sumbmitAgreement(symbol){
    var type = 0 ;
    var array = document.getElementsByName("agreeTradeContent");
    for(var i= 0 ; i < array.length ; i++){
        var obj = array[i];
        if(obj.checked == true){
            type = obj.value;
            break;
        }
    }

    if(type != 1){
        closeEntrustAgreement();
        return ;
    }
    var url = "/strategy/signedProtocol.do";
    jQuery.post(url,null,function(data){
        if(data == 0 ){
            var toType = document.getElementById("toType").value;
            window.location.href = "/trade/strategy.do?type="+toType+"&symbol="+symbol;
        }

    });


}

function sumbmitAgreement_new(symbol){
    var type = 0 ;
    var array = document.getElementsByName("agreeTradeContent");
    for(var i= 0 ; i < array.length ; i++){
        var obj = array[i];
        if(obj.checked == true){
            type = obj.value;
            break;
        }
    }

    if(type != 1){
        closeEntrustAgreement();
        return ;
    }
    var url = "/strategy/signedProtocol.do";
    jQuery.post(url,null,function(data){
        if(data == 0 ){
            var toType = document.getElementById("toType").value;
            window.location.href = "/trade/btc.do?type="+toType+"&symbol="+symbol;
        }

    });


}

function sellPlanSummoneyValueStragety(event){
    var type = document.getElementById("sellType");
    var amount = document.getElementById("sellAmount");
    var cnyPrice = document.getElementById("sellCnyPrice");
    var turnoverin = document.getElementById("sellTurnoverin");
    var feeTips = document.getElementById("sellFeeTips");
    var bitTips = document.getElementById("sellBtcTips");
    var feeTipsValue = document.getElementById("sellFeeTipsValue");
    summoneyValue(type,amount,cnyPrice,turnoverin,feeTips,feeTipsValue,bitTips,event);
}


function buyPlanBtc_new(){
    var buyAmount =document.getElementById("buyAmount").value;
    var buyCnyPrice =document.getElementById("buyCnyPrice").value;
    var buyPwd = trim(document.getElementById("buyPwd").value);
    var buyType = document.getElementById("buyType").value;
    var btcTips = document.getElementById("buyBtcTips");
    var btcTriggerPrice = document.getElementById("buyTriggerPrice").value;
    planBtcSubmitForm_new(buyAmount,buyCnyPrice,buyPwd,buyType,btcTips,btcTriggerPrice,"planToBuyBtc","planToSellBtc");
}
function sellPlanBtc_new(){
    var sellAmount =document.getElementById("sellAmount").value;
    var sellCnyPrice =document.getElementById("sellCnyPrice").value;
    var sellPwd = trim(document.getElementById("sellPwd").value);
    var sellType = document.getElementById("sellType").value;
    var btcTips = document.getElementById("sellBtcTips");
    var sellTriggerPrice = document.getElementById("sellTriggerPrice").value;
    planBtcSubmitForm_new(sellAmount,sellCnyPrice,sellPwd,sellType,btcTips,sellTriggerPrice,"planToBuyBtc","planToSellBtc");
}

function planBtcSubmitForm_new(tradeAmount,tradeCnyPrice,tradePwd,tradeType,btcTips,btcTriggerPrice,subBthOne,subBthTwo){
    if(check == 2){
        return;
    }
    var btcStr = tradeType==1?subBthOne:subBthTwo;

    var symbol = document.getElementById("symbol").value;
    var isopen = document.getElementById("isopen").value;
    var marketed;
    if(tradeType ==1){
        marketed = document.getElementById("buyMarketedType").value;
        if(marketed == 0){
            var tradeTurnover = tradeAmount*tradeCnyPrice;
            if(document.getElementById("userCnyBalance")!=null &&  Number(document.getElementById("userCnyBalance").value) <  Number(tradeTurnover)){
                alertTipsSpan(btcTips,balanceisinsufficient);
                return;
            }else{
                clearTipsSpan(btcTips);
            }
            if(btcTriggerPrice== null || btcTriggerPrice == ""){
                alertTipsSpan(btcTips,setfundspassword);
                return;
            }
        }else{
            tradeCnyPrice = btcTriggerPrice;
            if(document.getElementById("userCnyBalance")!=null &&  Number(document.getElementById("userCnyBalance").value) < Number(tradeAmount)){
                alertTipsSpan(btcTips,balanceisinsufficient);
                return;
            }else{
                clearTipsSpan(btcTips);
            }
        }
    }else{
        if(document.getElementById("userBtcBalance")!=null &&  Number(document.getElementById("userBtcBalance").value) <  Number(tradeAmount)){
            //newCoinLabel
            if(symbol == 0){
                alertTipsSpan(btcTips,buytradejs2);
            }else if (symbol == 1) {
                alertTipsSpan(btcTips,buytradejs3);
            }
            return;
        }else{
            clearTipsSpan(btcTips);
        }
        marketed = document.getElementById("sellMarketedType").value;
        if(marketed==1){
            tradeCnyPrice = btcTriggerPrice;
        }else{
            if(btcTriggerPrice== null || btcTriggerPrice == ""){
                alertTipsSpan(btcTips,setfundspassword);
                return;
            }
        }
    }

    var reg = new RegExp("^[0-9]+\.{0,1}[0-9]{0,8}$");
    if(!reg.test(tradeAmount) ){
        alertTipsSpan(btcTips,buytradejs4);
        return;
    }else{
        clearTipsSpan(btcTips);
    }
    //newCoinLabel
    if(symbol == 0){
        if(tradeAmount < 0.01){
            alertTipsSpan(btcTips,buytradejs6);
            return;
        }else{
            clearTipsSpan(btcTips);
        }
    }else if (symbol == 1){
        if(tradeAmount < 0.1){
            alertTipsSpan(btcTips,buytradejs5);
            return;
        }else{
            clearTipsSpan(btcTips);
        }
    }

    if(!reg.test(tradeCnyPrice) ){
        alertTipsSpan(btcTips,buytradejs7);
        return;
    }else{
        clearTipsSpan(btcTips);
    }
    if(tradePwd == "" && isopen != 1){
        alertTipsSpan(btcTips,entertransactionpassword);
        return;
    }else{
        btcTips.style.display="";
        btcTips.innerHTML="&nbsp;";
    }

    if(marketed ==1 && tradeType == 1){
        //newCoinLabel
        if(symbol == 0){
            if(accDiv(tradeAmount, tradeCnyPrice) < 0.01){
                alertTipsSpan(btcTips,buytradejs6);
                return;
            }
        }else if (symbol == 1){
            if(accDiv(tradeAmount, tradeCnyPrice) < 0.1){
                alertTipsSpan(btcTips,buytradejs5);
                return;
            }
        }
    }else{
        btcTips.style.display="";
        btcTips.innerHTML="&nbsp;";
    }

    tradePwd = isopen==1?"":tradePwd;
    var url = "/trade/planBtcSubmit.do?random="+Math.round(Math.random()*100);
    var param={tradeAmount:tradeAmount,tradeCnyPrice:tradeCnyPrice,tradePwd:tradePwd,type:tradeType,symbol:symbol,marketed:marketed,triggerPrice:btcTriggerPrice};
    check = 2;
    disabledStation(btcStr);
    jQuery.post(url,param,function(data){
        var result = eval('(' + data + ')');
        if(result!=null){
            if(result.resultCode != 0){
                check = 1;
            }
            if(result.resultCode == -5){
                if(result.errorNum == 0){
                    alertTipsSpan(btcTips,buytradejs10);
                }else{
                    alertTipsSpan(btcTips,buytradejs11+youhave+result.errorNum+chancesleft);
                }
                if(tradeType == 1){
                    if(document.getElementById("buyPwd") != null){
                        document.getElementById("buyPwd").value = "";
                    }
                }else{
                    if(document.getElementById("sellPwd") != null){
                        document.getElementById("sellPwd").value = "";
                    }
                }
            }else if(result.resultCode == -2){
                alertTipsSpan(btcTips,buytradejs13);
            }else if(result.resultCode == -3){
                //newCoinLabel
                if(symbol == 0){
                    alertTipsSpan(btcTips,buytradejs8);
                }else if (symbol == 1){
                    alertTipsSpan(btcTips,buytradejs9);
                }
            }else if(result.resultCode == -4){
                alertTipsSpan(btcTips,buytradejs13);
            }else if(result.resultCode == -1){
                alertTipsSpan(btcTips,setfundspassword);
            }else if(result.resultCode == -6){
                //newCoinLabel
                if(symbol == 0){
                    alertTipsSpan(btcTips,buytradejs2);
                }else if (symbol == 1) {
                    alertTipsSpan(btcTips,buytradejs3);
                }
            }else if(result.resultCode == -7){
                //newCoinLabel
                if(symbol == 0){
                    alertTipsSpan(btcTips,selltradejs3);
                }else if (symbol == 1) {
                    alertTipsSpan(btcTips,selltradejs4);
                }
            }else if(result.resultCode == -8){
                alertTipsSpan(btcTips,buytradejs13);
            }else if(result.resultCode == -10){
                //newCoinLabel
                if(symbol == 0){
                    alertTipsSpan(btcTips,orderspricelesslastprice+"，"+youcould+"<a href='/trade/btc.do?tradeType=0'>"+" "+buyin+"</a>");
                }else if (symbol == 1) {
                    alertTipsSpan(btcTips,orderspricelesslastprice+"，"+youcould+"<a href='/trade/ltc.do?tradeType=0'>"+" "+buyin+"</a>");
                }
            }else if(result.resultCode == -11){
                //newCoinLabel
                if(symbol == 0){
                    alertTipsSpan(btcTips,orderspricelargelastprice+"，"+youcould+"<a href='/trade/btc.do?tradeType=1'>"+" "+sellout+"</a>");
                }else if (symbol == 1) {
                    alertTipsSpan(btcTips,orderspricelargelastprice+"，"+youcould+"<a href='/trade/ltc.do?tradeType=1'>"+" "+sellout+"</a>");
                }
            }else if(result.resultCode == -13){
                alertTipsSpan(btcTips,buytradejs19);
            }else if(result.resultCode == -14){
                alertTipsSpan(btcTips,buytradejs17);
            }else if(result.resultCode == -15){
                alertTipsSpan(btcTips,entertransactionpassword);
            }else if(result.resultCode == -17){
                alertTipsSpan(btcTips,requiredinfo);
            }else if(result.resultCode == -200){
            	alertTipsSpan(btcTips,get$("youfreezebymasterxia"));
            }else if(result.resultCode == 3){
                alertTipsSpan(btcTips,buytradejs20);
            }else if(result.resultCode >0){
                //waitingStation(subBthOne,insubmiting);
                //disabledStation(subBthTwo);
                check = 1;
                alertTipsSpan(btcTips,"委托成功");
                if(result.errorNum == 1000){
                    jQuery(".planTradePwd").hide();
                    document.getElementById("isopen").value = 1;
                }
            }
            enabledStation(btcStr);
        }
    });
}

function trackEntrust_new(symbol,type,suffix){
    if(type == 1){
        var tradeValue = document.getElementById("buyTradeValue").value;
        var ratio = document.getElementById("buyRatio").value;
        var protePrice = document.getElementById("buyProtePrice").value;
        var pwd = document.getElementById("trackBuyPwd").value;

        submitTrackEntrust_new(symbol,type,tradeValue,ratio,protePrice,pwd,"tacticBthBuy","tacticBthSell",suffix);
    }else{
        var tradeValue = document.getElementById("sellTradeValue").value;
        var ratio = document.getElementById("sellRatio").value;
        var protePrice = document.getElementById("sellProtePrice").value;
        var pwd = document.getElementById("trackSellPwd").value;

        submitTrackEntrust_new(symbol,type,tradeValue,ratio,protePrice,pwd,"tacticBthSell","tacticBthBuy",suffix);
    }
}

function alertSpanTigs_new(type,content,suffix){
    if(type == 1){
        document.getElementById("buyTrackTigs"+suffix).innerHTML=content;
    }else{
        document.getElementById("sellTrackTigs"+suffix).innerHTML=content;
    }
    setTimeout(function (){
        clearSpanTigs_new(type,suffix);
    },3000);
}

function clearSpanTigs_new(type,suffix){
    if(type == 1){
        document.getElementById("buyTrackTigs"+suffix).innerHTML="";
    }else{
        document.getElementById("sellTrackTigs"+suffix).innerHTML="";
    }
}

function submitTrackEntrust_new(symbol,type,tradeValue,range,protePrice,pwd,tacticBthOne,tacticBthTwo,suffix){
    if(trackCheck == 2){
        return ;
    }
    var btnStr = type==1?tacticBthOne:tacticBthTwo;

    var symbolName = SYMBOLS_UTIL.symbolStr1[symbol];
    if(tradeValue == null || tradeValue == ""){
        if(type == 1){
            alertSpanTigs_new(type,requiredbidamount,suffix);
        }else{
            alertSpanTigs_new(type,quantityrequired,suffix);
        }
        return ;
    }

    if(range == null || range == ""){
        alertSpanTigs_new(type,callbackrequired,suffix);
        return ;
    }
    if(range>99.99){
        alertSpanTigs_new(type,cannotgreatethan,suffix);
        return ;
    }
    if(range<0.01){
        alertSpanTigs_new(type,cannotlessthan,suffix);
        return ;
    }
    if(protePrice == null || protePrice == ""){
        if(type == 1){
            alertSpanTigs_new(type,buypricenotnull,suffix);
        }else{
            alertSpanTigs_new(type,sellpricenotnull,suffix);
        }
        return ;
    }
    trackCheck = 2 ;
    clearSpanTigs_new(type,suffix);
    var url = "/strategy/submitTrackEntrust.do?random="+Math.round(Math.random()*100);
    var param={symbol:symbol,type:type,tradeValue:tradeValue,range:range,protePrice:protePrice,tradePwd:pwd};
    disabledStation(btnStr);
    jQuery.post(url,param,function(data){
        var result = eval('(' + data + ')');
        if(result!=null){
            if(result.resultCode != 0 ){
                trackCheck = 1 ;
            }
            if(result.resultCode == -1){
                alertSpanTigs_new(type,contactcustomer,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -2){
                alertSpanTigs_new(type,infonotbenull,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -3){
                alertSpanTigs_new(type,mustbetween,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -4 || result.resultCode == -12){
                alertSpanTigs_new(type,insufficientbalance,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -5){
                alertSpanTigs_new(type,accountfrozen,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -6){
                alertSpanTigs_new(type,forcedliquidation,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -7){
                alertSpanTigs_new(type,setfundspass,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -8){
                alertSpanTigs_new(type,failedattempts,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -9){
                alertSpanTigs_new(type,passporttimeout,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -10){
                alertSpanTigs_new(type,entertranpass,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -11){
                alertSpanTigs_new(type,incorrectremain+result.errorNum+incorrectnumbs,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -13){
                var str = "";
                if(type == 1){
                    str = error_buy;
                }else{
                    str = error_sell;
                }
                //newCoinLabel
                if(symbol == 0){
                    alertSpanTigs_new(type,cannotbeless+str+"0.01"+symbolName+"！",suffix);
                }else if (symbol == 1) {
                    alertSpanTigs_new(type,cannotbeless+str+"0.1"+symbolName+"！",suffix);
                }
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -17 ){
                alertSpanTigs_new(type,notyetagreed,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -14){
                alertSpanTigs_new(type,placeordererror,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -200){
            	alertSpanTigs_new(type,get$("youfreezebymaster"),suffix);
            	enabledStation(btnStr);
            	return ;
            }else if(result.resultCode == 0 ){
                trackCheck = 1 ;

                clearParamters(type);
                alertSpanTigs_new(type,"委托成功",suffix);
                enabledStation(btnStr);
                if(result.errorNum == 1000) {
                    jQuery(".adminTradePwd").hide();
                    document.getElementById("isopen").value = 1;
                }
            }
        }
    });
}

/**
 * 交易中心Tab切换。最近十笔未成交 / 历史委托
 * onclick方法
 * */
function refrushRecord_new(symbol,type,sign){
    TimerComTask.clearTimerInterval(INTERVAL_ID.trade_entrust_time);
    var _main_pre_url_strategy = jQuery("#_main_pre_url_strategy").val();
    if(sign==1){
        document.getElementById("realEntrustType").value=-1;
    }else if(sign==2){
        document.getElementById("realEntrustType").value=2;
    }
    document.getElementById("sign").value=sign;
    var showDiv = "";
    var loadDiv = "";
    var sufStr = "";
    type = parseInt(type);
    switch (type){
        case 1 :
            showDiv = "entrustInfo";
            loadDiv = "_data_normal";
            sufStr = "_n";
            break;
        case 2 :
            showDiv = "entrustInfo";
            loadDiv = "_data_normal";
            sufStr = "_n";
            break;
        case 3 :
            showDiv = "entrustInfo_plan";
            loadDiv = "_data_plan";
            sufStr = "_p";
            break;
        case 4 :
            showDiv = "entrustInfo_track";
            loadDiv = "_data_track";
            sufStr = "_t";
            break;
        case 5 :
            showDiv = "entrustInfo_ice";
            loadDiv = "_data_ice";
            sufStr = "_i";
            break;
        case 6 :
            showDiv = "entrustInfo_time";
            loadDiv = "_data_time";
            sufStr = "_d";
            break;
    }
    if(sign==2){//切换标题显示
        document.getElementById("his"+sufStr).setAttribute("class","cur");
        document.getElementById("cur"+sufStr).setAttribute("class","");
    }else{
        document.getElementById("his"+sufStr).setAttribute("class","");
        document.getElementById("cur"+sufStr).setAttribute("class","cur");
    }
    displayAllEntrustDiv();
    selectEntrustTal(type);
    var url = "/strategy/refrushRecordNew.do?symbol="+symbol+"&type="+type+"&sign="+sign+"&strategyType="+(type-3);
    var oldType = type;

    // 最近10笔未成交
    if(type == 1 || type == 2){
        type = sign!=2 ? 0 : type;//0最近十笔
        url = "/trade/entrustInfoNew.do?symbol="+symbol+"&type="+type+"&sign="+sign+"&strategyType="+type;
    }

    // 展示loading
    var htmlStr = "<span style='margin-top:5px;display:block;text-align: center'><img style='height: 12px;' src='"+_main_pre_url_strategy+"/image/common/loading.gif'></span>";
    document.getElementById(loadDiv).innerHTML= htmlStr;
    jQuery("#"+showDiv).show();

    jQuery.post(url, null, function(data){
        if (data == null || data == "") {
            return;
        }
        jQuery("#"+loadDiv).html(data);
    });
    // 交易中心最近十笔未成交和历史委托的 oldType=1，并不轮询
    if (oldType != 1 && sign != 2) {
        INTERVAL_ID.trade_entrust_time=setInterval(function (){
            refrushRecord_push(symbol,type,sign);
        },TimerComTask.timer);
    }
}
//数据刷新使用
function refrushRecord_push(symbol,type,sign){
    if(sign==1){
        document.getElementById("realEntrustType").value=-1;
    }else if(sign==2){
        document.getElementById("realEntrustType").value=2;
    }
    var showDiv = "";
    var loadDiv = "";
    var sufStr = "";
    type = parseInt(type);
    switch (type){
        case 1 :
            showDiv = "entrustInfo";
            loadDiv = "_data_normal";
            sufStr = "_n";
            break;
        case 2 :
            showDiv = "entrustInfo";
            loadDiv = "_data_normal";
            sufStr = "_n";
            break;
        case 3 :
            showDiv = "entrustInfo_plan";
            loadDiv = "_data_plan";
            sufStr = "_p";
            break;
        case 4 :
            showDiv = "entrustInfo_track";
            loadDiv = "_data_track";
            sufStr = "_t";
            break;
        case 5 :
            showDiv = "entrustInfo_ice";
            loadDiv = "_data_ice";
            sufStr = "_i";
            break;
        case 6 :
            showDiv = "entrustInfo_time";
            loadDiv = "_data_time";
            sufStr = "_d";
            break;
    }
    var url = "/strategy/refrushRecordNew.do?symbol="+symbol+"&type="+type+"&sign="+sign+"&strategyType="+(type-3);

    if (type==1 || type==2) {
        type = sign != 2 ? 0 : type;
        url = "/trade/entrustInfoNew.do?symbol="+symbol+"&type="+type+"&sign="+sign+"&strategyType="+type;
        if(isConnect){
            //推送连接成功停止
            return;
        }
    }
    jQuery.post(url,null,function(data){
        if (data == null || data == "") {
            return;
        }
        jQuery("#"+loadDiv).html(data);
    });
}



// 【现货交易中心】轮询 最近10笔刷新
function refrushRecord_push_pack(){
    var symbol = document.getElementById("symbol").value;
    var type = document.getElementById("selectValue").value;
    var sign = document.getElementById("sign").value;

    // 历史委托直接返回，不刷新
    if(sign==2){
        return;
    }

    if(sign==1){
        document.getElementById("realEntrustType").value=-1;
    }else if(sign==2){
        document.getElementById("realEntrustType").value=2;
    }
    var showDiv = "";
    var loadDiv = "";
    var sufStr = "";
    type = parseInt(type);
    switch (type){
        case 1 :
            showDiv = "entrustInfo";
            loadDiv = "_data_normal";
            sufStr = "_n";
            break;
        case 2 :
            showDiv = "entrustInfo";
            loadDiv = "_data_normal";
            sufStr = "_n";
            break;
        case 3 :
            showDiv = "entrustInfo_plan";
            loadDiv = "_data_plan";
            sufStr = "_p";
            break;
        case 4 :
            showDiv = "entrustInfo_track";
            loadDiv = "_data_track";
            sufStr = "_t";
            break;
        case 5 :
            showDiv = "entrustInfo_ice";
            loadDiv = "_data_ice";
            sufStr = "_i";
            break;
        case 6 :
            showDiv = "entrustInfo_time";
            loadDiv = "_data_time";
            sufStr = "_d";
            break;
    }
    var url = "/strategy/refrushRecordNew.do?symbol="+symbol+"&type="+type+"&sign="+sign+"&strategyType="+(type-3);

    if(type == 1 || type == 2){
        type = sign != 2 ? 0 : type;
        url = "/trade/entrustInfoNew.do?symbol="+symbol+"&type="+type+"&sign="+sign+"&strategyType="+type;
    }

    jQuery.post(url,null,function(data){
        if (data == null || data == "") {
            return;
        }
        jQuery("#"+loadDiv).html(data);
    });
}





//将所有div隐藏并清空数据
function displayAllEntrustDiv(){
    jQuery("#entrustInfo").hide();
    jQuery("#entrustInfoHis").hide();
    jQuery("#entrustInfo_plan").hide();
    jQuery("#entrustInfo_track").hide();
    jQuery("#entrustInfo_ice").hide();
    jQuery("#entrustInfo_time").hide();

    jQuery("#_data_entrustInfo").innerHTML="";
    jQuery("#_data_plan").innerHTML="";
    jQuery("#_data_track").innerHTML="";
    jQuery("#_data_time").innerHTML="";
    jQuery("#_data_ice").innerHTML="";
    jQuery("#entrustInfoHis").innerHTML="";

    var objNormal = document.getElementsByName("entrust_normal");
    var objPlan = document.getElementsByName("entrust_plan");
    var objTrack = document.getElementsByName("entrust_track");
    var objIce = document.getElementsByName("entrust_ice");
    var objTime = document.getElementsByName("entrust_time");
    for(k=0;k< objNormal.length;k++){
        objNormal[k].setAttribute("class","submitButton futurePlanButton");
    }
    for(k=0;k< objPlan.length;k++){
        objPlan[k].setAttribute("class","submitButton futurePlanButton");
    }
    for(k=0;k< objTrack.length;k++){
        objTrack[k].setAttribute("class","submitButton futurePlanButton");
    }
    for(k=0;k< objIce.length;k++){
        objIce[k].setAttribute("class","submitButton futurePlanButton");
    }
    for(k=0;k< objTime.length;k++){
        objTime[k].setAttribute("class","submitButton futurePlanButton");
    }
}

function selectEntrustTal(val){
    var valT = parseInt(val);
    switch (valT){
        case 1:
            var objNormal = document.getElementsByName("entrust_normal");
            for(k=0;k< objNormal.length;k++){
                objNormal[k].setAttribute("class","submitButton futurePlanButtoncur");
            }
            break;
        case 2:
            var objNormal = document.getElementsByName("entrust_normal");
            for(k=0;k< objNormal.length;k++){
                objNormal[k].setAttribute("class","submitButton futurePlanButtoncur");
            }
            break;
        case 3:
            var objPlan = document.getElementsByName("entrust_plan");
            for(k=0;k< objPlan.length;k++){
                objPlan[k].setAttribute("class","submitButton futurePlanButtoncur");
            }
            break;
        case 4:
            var objTrack = document.getElementsByName("entrust_track");
            for(k=0;k< objTrack.length;k++){
                objTrack[k].setAttribute("class","submitButton futurePlanButtoncur");
            }
            break;
        case 5:
            var objIce = document.getElementsByName("entrust_ice");
            for(k=0;k< objIce.length;k++){
                objIce[k].setAttribute("class","submitButton futurePlanButtoncur");
            }
            break;
        case 6:
            var objTime = document.getElementsByName("entrust_time");
            for(k=0;k< objTime.length;k++){
                objTime[k].setAttribute("class","submitButton futurePlanButtoncur");
            }
            break;
    }
}


function continuousEntrust_new(symbol,type,suffix){
    if(type == 1){
        var tradeValue = document.getElementById("buyTradeValue"+suffix).value;
        var singleAvg = document.getElementById("buySingleAvg"+suffix).value;
        var depthRange = document.getElementById("buyDepthRange"+suffix).value;
        var protePrice = document.getElementById("buyProtePrice"+suffix).value;
        var pwd = document.getElementById("trackBuyPwd"+suffix).value;
        var signs = document.getElementById("buySign").value;
        submitContinuousEntrust_new(symbol,type,tradeValue,singleAvg,depthRange,protePrice,pwd,signs,"iceBthBuy"+suffix,"iceBthSell"+suffix,suffix);
    }else{
        var tradeValue = document.getElementById("sellTradeValue"+suffix).value;
        var singleAvg = document.getElementById("sellSingleAvg"+suffix).value;
        var depthRange = document.getElementById("sellDepthRange"+suffix).value;
        var protePrice = document.getElementById("sellProtePrice"+suffix).value;
        var pwd = document.getElementById("trackSellPwd"+suffix).value;
        var signs = document.getElementById("sellSign").value;
        submitContinuousEntrust_new(symbol,type,tradeValue,singleAvg,depthRange,protePrice,pwd,signs,"iceBthBuy"+suffix,"iceBthSell"+suffix,suffix);
    }
}


function submitContinuousEntrust_new(symbol,type,tradeValue,singleAvg,depthRange,protePrice,pwd,signs,iceBthOne,iceBthTwo,suffix){
    if(conCheck == 2){
        return ;
    }
    var symbolName = SYMBOLS_UTIL.symbolStr1[symbol];
    var btnStr = type==1?iceBthOne:iceBthTwo;
    if(tradeValue == null || tradeValue == ""){
        if(type == 1){
            alertSpanTigs_new(type,buyamountrequired,suffix);
        }else{
            alertSpanTigs_new(type,sellamountrequired,suffix);
        }
        return ;
    }
    if(singleAvg == null || singleAvg == ""){
        if(type == 1){
            alertSpanTigs_new(type,singlebuyaveragenotnull,suffix);
        }else{
            alertSpanTigs_new(type,singlesellaveragenotnull,suffix);
        }
        return ;
    }


    if(type == 1 ){
        if(singleAvg >100000){
            alertSpanTigs_new(type,cannotgreaterthan,suffix);
            return ;
        }
    }else{
        //newCoinLabel
        if(symbol == 0  && singleAvg > 100){
            alertSpanTigs_new(type,cannotgreaterthanbtc,suffix);
            return ;
        }else if(symbol == 1 && singleAvg > 1000){
            alertSpanTigs_new(type,cannotgreaterthanltc,suffix);
            return ;
        }
    }

    if(depthRange == null || depthRange == ""){
        alertSpanTigs_new(type,depthrequired,suffix);
        return ;
    }
    if(depthRange<0 || depthRange >0.5){
        alertSpanTigs_new(type,rangemustbetween,suffix);
        return ;
    }
    if(protePrice == null || protePrice == ""){
        if(type == 1){
            alertSpanTigs_new(type,highestrequired,suffix);
        }else{
            alertSpanTigs_new(type,minimumrequired,suffix);
        }
        return ;
    }
    if(signs == 2){
        depthRange = "-"+depthRange;
    }
    conCheck = 2 ;
    clearSpanTigs_new(type,suffix);
    var url = "/strategy/submitContinousEntrust.do?random="+Math.round(Math.random()*100);
    var param={symbol:symbol,type:type,tradeValue:tradeValue,singleAvg:singleAvg,depthRange:depthRange,protePrice:protePrice,tradePwd:pwd};
    disabledStation(btnStr);
    jQuery.post(url,param,function(data){
        var result = eval('(' + data + ')');
        if(result!=null){
            if(result.resultCode != 0 ){
                conCheck = 1 ;
            }
            if(result.resultCode == -1){
                alertSpanTigs_new(type,informationrequired,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -2){
                alertSpanTigs_new(type,depthtoolarge,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -3 || result.resultCode == -11){
                alertSpanTigs_new(type,insufficientbalance,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -4){
                alertSpanTigs_new(type,accountfrozen,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -5){
                alertSpanTigs_new(type,forcedliquidation,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -6){
                alertSpanTigs_new(type,setfundspass,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -7){
                alertSpanTigs_new(type,failedattempts,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -8){
                alertSpanTigs_new(type,passporttimeout,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -9){
                alertSpanTigs_new(type,entertranpass,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -10){
                alertSpanTigs_new(type,incorrectremain+result.errorNum+incorrectnumbs,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -12){
                var str = "";
                if(type == 1){
                    str = error_buy;
                }else{
                    str = error_sell;
                }
                //newCoinLabel
                if(symbol == 0 ){
                    alertSpanTigs_new(type,cannotbeless+str+"0.01"+symbolName+"！",suffix);
                }else if (symbol == 1) {
                    alertSpanTigs_new(type,cannotbeless+str+"0.1"+symbolName+"！",suffix);
                }
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -13){
                alertSpanTigs_new(type,placeordererror,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -17 ){
                alertSpanTigs_new(type,notyetagreed,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -200 ){
            	alertSpanTigs_new(type,get$("youfreezebymaster"),suffix);
            	enabledStation(btnStr);
            	return ;
            }else if(result.resultCode == -14){
                if(type == 1){
                    alertSpanTigs_new(type,cannotgreaterthan,suffix);
                }else{
                    //newCoinLabel
                    if(symbol == 0){
                        alertSpanTigs_new(type,cannotgreaterthanbtc,suffix);
                    }else if (symbol == 1) {
                        alertSpanTigs_new(type,cannotgreaterthanltc,suffix);
                    }
                }
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == 0 ){
                conCheck = 1 ;
                clearContinuous_new(type,suffix);
                enabledStation(btnStr);
                alertSpanTigs_new(type,"委托成功",suffix);
                if(result.errorNum == 1000) {
                    jQuery(".adminTradePwd").hide();
                    document.getElementById("isopen").value = 1;
                }
            }
        }
    });
}

function clearContinuous_new(type,suffix){
    if(type == 1){
        document.getElementById("buyTradeValue"+suffix).value="";
        document.getElementById("buySingleAvg"+suffix).value="";
        document.getElementById("buyDepthRange"+suffix).value="";
        document.getElementById("buyProtePrice"+suffix).value="";
        document.getElementById("trackBuyPwd"+suffix).value="";

    }else{
        document.getElementById("sellTradeValue"+suffix).value="";
        document.getElementById("sellSingleAvg"+suffix).value="";
        document.getElementById("sellDepthRange"+suffix).value="";
        document.getElementById("sellProtePrice"+suffix).value="";
        document.getElementById("trackSellPwd"+suffix).value="";

    }
}

function iniEntrust_new(symbol,type,suffix){
    if(type==1){
        var tradeValue = document.getElementById("buyTradeValue"+suffix).value;
        var priceRange = document.getElementById("buyPriceRange"+suffix).value;
        var orderRatio = document.getElementById("buyOrderRatio"+suffix).value;
        var protePrice = document.getElementById("buyProtePrice"+suffix).value;
        var orderInterval = document.getElementById("buyOrderInterval"+suffix).value;
        var pwd = document.getElementById("trackBuyPwd"+suffix).value;
        var singleMax = document.getElementById("buySingleMax"+suffix).value;
        submitIniEntrust_new(symbol,type,tradeValue,priceRange,orderRatio,singleMax,protePrice,orderInterval,pwd,"timeBthBuy"+suffix,"timeBthSell"+suffix,suffix);

    }else{
        var tradeValue = document.getElementById("sellTradeValue"+suffix).value;
        var priceRange = document.getElementById("sellPriceRange"+suffix).value;
        var orderRatio = document.getElementById("sellOrderRatio"+suffix).value;
        var protePrice = document.getElementById("sellProtePrice"+suffix).value;
        var orderInterval = document.getElementById("sellOrderInterval"+suffix).value;
        var pwd = document.getElementById("trackSellPwd"+suffix).value;
        var singleMax = document.getElementById("sellSingleMax"+suffix).value;
        submitIniEntrust_new(symbol,type,tradeValue,priceRange,orderRatio,singleMax,protePrice,orderInterval,pwd,"timeBthBuy"+suffix,"timeBthSell"+suffix,suffix);
    }
}


function submitIniEntrust_new(symbol,type,tradeValue,priceRange,orderRatio,singleMax,protePrice,orderInterval,pwd,timeBthOne,timeBthTwo,suffix){
    if(iniCheck == 2){
        return ;
    }
    var btnStr = type==1?timeBthOne:timeBthTwo;
    var symbolName = SYMBOLS_UTIL.symbolStr1[symbol];
    if(tradeValue == null || tradeValue == ""){
        if(type == 1){
            alertSpanTigs_new(type,buyamountrequired,suffix);
        }else{
            alertSpanTigs_new(type,buyquantityrequired,suffix);
        }
        return ;
    }
    if(priceRange == null || priceRange == ""){
        alertSpanTigs_new(type,sweepratiorequired,suffix);
        return null;
    }
    if(priceRange<0 || priceRange>5){
        alertSpanTigs_new(type,sweepmustbetween,suffix);
        return null;
    }
    if(singleMax == null || singleMax == ""){
        alertSpanTigs_new(type,singleentrustrequired,suffix);
        return null;
    }
    if(type == 1&&(singleMax<1000 || singleMax >100000 )){
        alertSpanTigs_new(type,singleentrustbetween,suffix);
        return null;
    }else if(type == 2){
        //newCoinLabel
        if(symbol == 0 && (singleMax <0.1 || singleMax >10)){
            alertSpanTigs_new(type,singleentrustshould+"0.1-10"+symbolName+between,suffix);
            return;
        }else if(symbol == 1 && (singleMax < 10 || singleMax > 1000)){
            alertSpanTigs_new(type,singleentrustshould+"10-1000"+symbolName+between,suffix);
            return;
        }

    }
    if(orderRatio == null || orderRatio == ""){
        alertSpanTigs_new(type,sweepratio,suffix);
        return null;
    }

    if(orderRatio<0.1 || orderRatio>100){
        alertSpanTigs_new(type,sweepratiobetween,suffix);
        return null;
    }

    if(protePrice == null || protePrice == ""){
        if(type == 1){
            alertSpanTigs_new(type,highestrequired,suffix);
        }else{
            alertSpanTigs_new(type,minimumrequired,suffix);
        }
        return ;
    }

    if(orderInterval == null || orderInterval == ""){
        alertSpanTigs_new(type,intervalrequired,suffix);
        return ;
    }

    if(orderInterval <1 || orderInterval >=600){
        alertSpanTigs_new(type,intervalbetween,suffix);
        return ;
    }
    iniCheck =2 ;
    clearSpanTigs_new(type,suffix);
    var param = {symbol:symbol,type:type,tradeValue:tradeValue,priceRange:priceRange,orderRatio:orderRatio,singleMax:singleMax,protePrice:protePrice,orderInterval:orderInterval,tradePwd:pwd};
    var url = "/strategy/submitInitiativeEntrust.do?random="+Math.round(Math.random()*100);
    disabledStation(btnStr);
    jQuery.post(url,param,function(data){
        var result = eval('(' + data + ')');
        if(result!=null){
            if(result.resultCode != 0 ){
                iniCheck = 1 ;
            }
            if(result.resultCode == -1){
                alertSpanTigs_new(type,infonotbenull,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -2){
                alertSpanTigs_new(type,sweepratioexceedslimit,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -3){
                alertSpanTigs_new(type,ratioexceedslimit,suffix);
                enabledStation(btnStr);
            }else if(result.resultCode == -4){
                alertSpanTigs_new(type,intervalexceedslimit,suffix);
                enabledStation(btnStr);
            }else if(result.resultCode == -5 || result.resultCode == -13){
                alertSpanTigs_new(type,insufficientbalance,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -6){
                alertSpanTigs_new(type,accountfrozen,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -7){
                alertSpanTigs_new(type,forcedliquidation,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -8){
                alertSpanTigs_new(type,setfundspass,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -9){
                alertSpanTigs_new(type,failedattempts,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -10){
                alertSpanTigs_new(type,passporttimeout,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -11){
                alertSpanTigs_new(type,entertranpass,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -12){
                alertSpanTigs_new(type,incorrectremain+result.errorNum+incorrectnumbs,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -14){
                var str = "";
                if(type == 1){
                    str = error_buy;
                }else{
                    str = error_sell;
                }
                //newCoinLabel
                if(symbol == 0 ){
                    alertSpanTigs_new(type,cannotbeless+str+"0.01"+symbolName+"！",suffix);
                }else if (symbol == 1) {
                    alertSpanTigs_new(type,cannotbeless+str+"0.1"+symbolName+"！",suffix);
                }
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -15){
                alertSpanTigs_new(type,placeordererror,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -16){
                if(type == 1){
                    alertSpanTigs_new(type,singleentrustbetween,suffix);
                    enabledStation(btnStr);
                    return null;
                }else if(type == 2){
                    //newCoinLabel
                    if(symbol == 0){
                        alertSpanTigs_new(type,singleentrustshould+"0.1-10"+symbolName+between,suffix);
                    }else if(symbol == 1){
                        alertSpanTigs_new(type,singleentrustshould+"10-1000"+symbolName+between,suffix);
                    }
                    enabledStation(btnStr);
                    return;
                }
            }else if(result.resultCode == -17 ){
                alertSpanTigs_new(type,notyetagreed,suffix);
                enabledStation(btnStr);
                return ;
            }else if(result.resultCode == -200 ){
            	alertSpanTigs_new(type,get$("youfreezebymaster"),suffix);
            	enabledStation(btnStr);
            	return ;
            }else if(result.resultCode == 0 ){
                iniCheck = 1 ;
                clearIniEntrust_new(type,suffix);
                alertSpanTigs_new(type,"委托成功",suffix);
                enabledStation(btnStr);
                if(result.errorNum == 1000) {
                    jQuery(".adminTradePwd").hide();
                    document.getElementById("isopen").value = 1;
                }
            }
        }
    });
}


function clearIniEntrust_new(type,suffix){
    if(type==1){
        document.getElementById("buyTradeValue"+suffix).value="";
        document.getElementById("buyPriceRange"+suffix).value="";
        document.getElementById("buyOrderRatio"+suffix).value="";
        document.getElementById("buyProtePrice"+suffix).value="";
        document.getElementById("buyOrderInterval"+suffix).value="";
        document.getElementById("trackBuyPwd"+suffix).value="";
        document.getElementById("buySingleMax"+suffix).value="";
    }else{
        document.getElementById("sellTradeValue"+suffix).value="";
        document.getElementById("sellPriceRange"+suffix).value="";
        document.getElementById("sellOrderRatio"+suffix).value="";
        document.getElementById("sellProtePrice"+suffix).value="";
        document.getElementById("sellOrderInterval"+suffix).value="";
        document.getElementById("trackSellPwd"+suffix).value="";
        document.getElementById("sellSingleMax"+suffix).value="";
    }
}

function cancelIniEntrust_new(id,symbol){
    var url = "/strategy/cancelInitiativeEntrust.do?random="+Math.round(Math.random()*100);
    var params = {id:id,symbol:symbol};
    jQuery.post(url,params,function(data){
        if(data==0){
            var obj = document.getElementsByName("initiative_"+id);
            if(obj){
                for(i=0;i<obj.length;i++){
                    obj[i].innerHTML= cancelled;
                }
            }
        }else if(data==-200){
        	var type = jQuery("#buyLi").hasClass("cur")?1:0;
        	alertSpanTigs_new(type,get$("youfreezebymastercancel"),"_time");
        }else{
            alert(undo_error);
        }
    });
}

function cancelContinuous_new(id,symbol){
    var url = "/strategy/cancelContinuousEntrust.do?random="+Math.round(Math.random()*100);
    var params = {id:id,symbol:symbol};
    jQuery.post(url,params,function(data){
        if(data==0){
            var obj = document.getElementsByName("continuous_"+id);
            if(obj){
                for(i=0;i<obj.length;i++){
                    obj[i].innerHTML= cancelled;
                }
            }
        }else if(data==-200){
        	var type = jQuery("#buyLi").hasClass("cur")?1:0;
        	alertSpanTigs_new(type,get$("youfreezebymastercancel"),"_ice");
        }else{
            alert(undo_error);
        }
    });
}

function cancelTrack_new(id,symbol){
    var url = "/strategy/cancelTrackEntrust.do?random="+Math.round(Math.random()*100);
    var params = {id:id,symbol:symbol};
    jQuery.post(url,params,function(data){
        if(data==0){
            var obj = document.getElementsByName("track_"+id);
            if(obj){
                for(i=0;i<obj.length;i++){
                    obj[i].innerHTML= cancelled;
                }
            }
            //document.getElementById("track_"+id).innerHTML=cancelled;
        }else if(data==-200){
        	var type = jQuery("#buyLi").hasClass("cur")?1:0;
        	var suffex="";
        	if(type==1){
        		suffex="_trace";
        	}
        	alertSpanTigs_new(type,get$("youfreezebymastercancel"),suffex);
        }else{
            alert(undo_error);
        }
    });
}

function cancelPlanEntrust_new(entrustId){
    var url = "/trade/cancelPlanEntrust.do?random="+Math.round(Math.random()*100);
    var currentPage = document.getElementById("currentPage").value;
    var symbol = document.getElementById("symbol").value;
    var param={entrustId:entrustId,symbol:symbol};
    jQuery.post(url,param,function(data){
        if(data == 0){
            var obj = document.getElementsByName("entrustStatus_"+entrustId);
            if(obj){
                for(i=0;i<obj.length;i++){
                    obj[i].innerHTML= cancelled;
                }
            }
        }else if(data==-200){
        	var type = jQuery("#buyLi").hasClass("cur")?1:0;
        	alertSpanTigs_new(type,get$("youfreezebymastercancel"),"");
		}else{
            alert(undo_error);
        }
    });
}